This application is based on and incorporates herein by reference Japanese Patent Application No. 2002-4755 filed on Jan. 11, 2002.
The present invention relates to a task switching technology that uses a real-time operating system.
In a control program used for an electronic control unit (ECU) mounted on a vehicle, for instance, it is required to execute predetermined processing in real-time for ensuring control responsiveness and safety. Therefore, the control program is defined in units of tasks which are assigned with respective priorities of execution. The tasks are switched by a real-time operating system (ROTS), and interrupt processing having a higher execution priority than tasks is executed with priority over the tasks.
For instance, when an interrupt request is made to the interrupt process in the middle of execution of the task, the interrupt process is executed in the course of the task. Normally, after the termination of the interrupt process, the interrupted task is executed.
It is however possible that the activation request for another task which has a higher priority over the interrupted task, for instance, is issued in the course of the interrupt process. In this instance, after the termination of the interrupt process, it is required to execute another task with priority over the interrupted task. For this reason, at the end of the interrupt processing, the RTOS executes task scheduling processing to determine the order of execution of processes and tasks. This task scheduling processing is executed not only at the time of termination of the interrupt process but also at the end of the task.
Although an interrupt prohibition interval is set within the task in some cases, the task scheduling processing is executed at the end of each interrupt prohibition interval as well. However, the task scheduling processing becomes useless at the end of the interrupt prohibition interval in some cases.
For instance, if the interrupt prohibition interval is assigned with the mask level which is higher than any other interrupt levels, no interrupt processes is allowed to interrupt in the interrupt prohibition interval. Therefore, in this instance, the task scheduling is useless and not desirable, because it takes time to be executed and lowers overall speed of execution of the processes and tasks.
The present invention has been made to overcome the above problem, and has an object to optimize a task scheduling process executed at the end of an interrupt prohibition interval.
According to the present invention, an electronic control unit has a control program. This control program includes tasks, interrupt processes and a real-time operating system (RTOS). The tasks have respective execution priorities and executed by switching. RTOS switches tasks based on activation requests of the tasks and the task levels. Interrupt processes are executed by interrupting the tasks and are assigned respective interrupt levels. An interrupt prohibition interval is set in predetermined tasks of the control program. The interrupt prohibition interval designates the interrupt level as a mask level so that an interrupt of the interrupt process of the lower interrupt level and switching of the tasks are prohibited. The control program is coded so that a task scheduling process that switches the tasks at the end of the interrupt prohibition interval is not executed under a predetermined condition in which it is clear that the tasks are not switched at the end of the interrupt prohibition interval.
The predetermined condition may be one of the following cases. The highest or much higher interrupt level among the interrupt levels of the interrupt processes that requests activation of the tasks in the interrupt prohibition interval is designated as the mask level. No task activation request is made in the interrupt prohibition interval, and it is only necessary that at least the interrupt of the interrupt processes which requests the activation is prohibited. The task level of the predetermined task having the interrupt prohibition interval has the highest task level.